<include file="public/header"/>
<style>
    .c {
        clear: both;
    }

    .shadow {
        display: none;
        background: #000000;
        width: 100%;
        height: 100%;
        left: 0;
        top: 0;
        filter: alpha(opacity=40);
        opacity: 0.4;
        z-index: 999;
        position: fixed;
        _position: absolute;
        _top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 : document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);
    }

    .popbox {
        display: none;
        z-index: 1001;
        width: 400px;
        height: 300px;
        background: #F7F7F7;
        border: 1px #999999 solid;
        position: fixed;
        top: 50%;
        left: 50%;
        margin: -50px 0px 0px -200px;
        _margin-top: 0px;
        _position: absolute;
        _top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 : document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);
    }

    .popbox h5 {
        height: 30px;
        line-height: 30px;
        padding: 1px 1px 1px 10px;
        background: #FFFFFF;
        border-bottom: 1px #999999 solid;
        font-size: 16px;
    }

    .popbox h5 #title {
        float: left;
        color: #0e90d2;
    }

    .popbox h5 #close {
        display: block;
        float: right;
        display: inline;
    }

    .popbox h5 #close:hover {
        background-position: -12px 0;
    }

    .popbox p {
        padding: 15px;
        font-size: 14px;
        text-align: center;
    }
</style>
<div class="am-cf admin-main">
<!-- sidebar start -->
<include file="public/sidebar"/>
<!-- sidebar end -->

<!-- content start -->
<div class="admin-content">
<div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">订单列表</strong></div>
    <div id="result"></div>
</div>

<div class="am-g">
    <div class="am-u-md-6 am-cf">
        <div class="am-fl am-cf">
            <div class="am-btn-toolbar am-fl">
                <div class="am-btn-group am-btn-group-xs">
                    <a href="{:U('User/lt2')}">
                        <button type="button" class="am-btn am-btn-primary am-btn-xs">
                            <span class="am-icon-plus"></span>新增
                        </button>
                    </a>
                    <!--belongGc-->
                    <if condition="$status eq 1">
                        <a id="getValue">
                            <button type="button" class="am-btn am-btn-success am-btn-xs">
                                批量分配工厂
                            </button>
                        </a>
                    </if>
                    <!--end-->
                    <!--psOrder-->
                    <if condition="$status eq 2">
                        <a id="getValuePs">
                            <button type="button" class="am-btn am-btn-success am-btn-xs">
                                批量配送
                            </button>
                        </a>
                    </if>
                    <!--end-->
                    <!--print-->
                    <if condition="$status eq 3">
                        <a id="getPrintValue">
                            <button type="button" class="am-btn am-btn-secondary am-btn-xs">
                                批量打印
                            </button>
                        </a>
                        <a id="getPsEndValue">
                            <button type="button" class="am-btn am-btn-success am-btn-xs">
                                批量完成配送
                            </button>
                        </a>
                        <if condition="session('role') eq 0">
                        <a id="getPsBelongValue">
                            <button type="button" class="am-btn am-btn-warning am-btn-xs">
                                批量分配配送
                            </button>
                        </a>
                        </if>
                    </if>
                    <!--end-->
                    <!--export-->
                    <if condition="$status eq 4">
                        <a href="{:U('Order/endListExport')}">
                            <button class="am-btn am-btn-success am-btn-xs">
                                <span class="am-icon-newspaper-o"></span>导出excel
                            </button>
                        </a>
                    </if>
                    <!--end-->
                </div>
            </div>
        </div>
    </div>
    <form method="post" action="__URL__/orderSearch/id/{$status}" class="am-form">
        <div class="am-form-group am-margin-left am-fl">
            <select name="select" id="select">
                <option value="user">客户</option>
                <option value="phone">手机</option>
                <option value="lts">量体师</option>
            </select>
        </div>
        <div class="am-u-md-3 am-cf">
            <div class="am-fr">
                <div class="am-input-group am-input-group-sm">
                    <input type="text" class="am-form-field" name="ifin" id="ifin">
                    <input type="hidden" name="status" value="{$status}"/>
                <span class="am-input-group-btn">
                  <button class="am-btn am-btn-default" type="submit">搜索</button>
                </span>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="am-g">
    <div class="am-u-sm-12">
        <table class="am-table am-table-striped am-table-hover table-main">
            <thead>
            <tr>
                <th class="table-check"><input type="checkbox" id="all"/></th>
                <th class="table-type">客户</th>
                <th class="table-type">手机</th>
                <th class="table-type">编号</th>
                <if condition="$status eq 3">
                    <th class="table-title">配送日期</th>
                    <th class="table-type">配送时间</th>
                </if>

                <th class="table-type">时间</th>
                <th class="table-id">数量</th>
                <th class="table-type">总金额</th>
                <th class="table-type">总定金</th>
                <if condition="$status eq 4">
                    <th class="table-type">余额</th>
                </if>
                <if condition="$status eq 3">
                    <th class="table-type">配送员</th>
                    <else/>
                    <th class="table-type">量体师</th>
                </if>

                <th class="table-type">状态</th>
                <th class="table-type">工厂</th>
                <th class="table-set">操作</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="datas" item="data">
                <tr>
                    <td><input type="checkbox" name="omid[]" class="check" value="{$data.omid}"/></td>
                    <td><a href="__URL__/../User/ltInfo/id/{$data.uid}">{$data.name}</a></td>
                    <td>{$data.phone}</td>
                    <if condition="$data.week eq 1">
                        <td class="am-danger" data-am-popover="{content:'订单时间超过7~10天内',trigger:'hover focus'}">
                            {$data.orderNum}
                        </td>
                        <elseif condition="$data.week eq 2"/>
                        <td data-am-popover="{content:'订单时间超过10天',trigger:'hover focus'}">
                            <span style="color: #b440ff;">{$data.orderNum}</span></td>
                        <else/>
                        <td>{$data.orderNum}</td>
                    </if>
                    <if condition="$status eq 3">
                        <td>{$data.ps_date}</td>
                        <td>{$data.ps}</td>
                    </if>
                    <if condition="$data.belong_gc neq null">
                    <td>{$data.gc_updated|date="Y-m-d H:i:s",###}</td>
                        <else/> 
                    <td>{$data.order_time|date="Y年m月d日 H:i:s",###}</td>
                    </if>
                    <td>
                        <if condition="$status eq 2">
                            <a href="__URL__/orderDetail/id/{$data.omid}">
                                {$data.zi_count}/{$data.count}
                            </a>
                            <else/>
                            {$data.count}
                        </if>
                    </td>
                    <td>{$data.price_count}</td>
                    <td>{$data.dj_count}</td>
                    <if condition="$status eq 4">
                        <td>{$data.pay_type}</td>
                    </if>
                    <if condition="$status eq 3">
                        <td>{$data.ps_yuan}</td>
                        <else/>
                        <td>{$data.belong}</td>
                    </if>

                    <switch name="data.status">
                        <case value="1">
                            <td>新订单</td>
                        </case>
                        <case value="2">
                            <td>工厂完工</td>
                        </case>
                        <case value="3">
                            <td>待配送</td>
                        </case>
                        <case value="4">
                            <td>已配送</td>
                        </case>
                        <case value="5">
                            <td>返工单</td>
                        </case>
                        <default/>
                        <td>返工完工</td>
                    </switch>
                    <td>{$data.belong_gc}</td>
                    <td>
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <!--分配工厂-start-->
                                <if condition="$data.status eq 1">
                                    <a href="__URL__/orderBelongGc/id/{$data.omid}">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                                            <span class="am-icon-pencil-square-o"></span>
                                            分配工厂
                                        </button>
                                    </a>
                                </if>
                                <!--分配工厂-end-->

                                <!--配送操作-开始-->
                                <if condition="($data.status eq 2) OR ($data.status eq 6) OR ($data.status eq 3)">
                                    <if condition="$data.isAllEnd eq 1">
                                    <a href="#" class="p{$data.omid}" onclick="ps(this.className)">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                                            <if condition="$data.status eq 3">
                                                重新配送
                                                <else/>
                                                配送
                                            </if>
                                        </button>
                                    </a>
                                    </if>
                                    <!--悬浮框-->
                                    <div class="shadow" id="p{$data.omid}"></div>
                                    <div class="popbox" id="pp{$data.omid}">
                                        <h5>
                                            <span id="title">配送时间</span>
                                            <a href="javascript:void(0);" id="close" title="Close">
                                                <!--<img src="__PUBLIC__/img/cha.jpg" style="width: 20px;height: 20px;"/>-->
                                                ×
                                            </a>
                                        </h5>

                                        <form class="am-form" action="__URL__/order_ps/id/{$data.omid}"
                                              method="post">
                                            <div class="am-g am-margin-top">
                                                <div class="am-u-sm-2 am-text-right">
                                                    日期
                                                </div>
                                                <div class="am-u-sm-4 am-u-end">
                                                    <input type="text" class="am-input-sm am-form-field "
                                                           id="ps_date" name="ps_date" onclick="laydate()">
                                                </div>
                                            </div>
                                            <div class="am-g am-margin-top">
                                                <div class="am-u-sm-2 am-text-right">
                                                    时间
                                                </div>
                                                <div class="am-u-sm-4 am-u-end">
                                                    <select id="ps" name="ps">
                                                        <option value="9:00~10:00">9:00~10:00</option>
                                                        <option value="10:00~11:00">10:00~11:00</option>
                                                        <option value="11:00~12:00">11:00~12:00</option>
                                                        <option value="12:00~13:00">12:00~13:00</option>
                                                        <option value="13:00~14:00">13:00~14:00</option>
                                                        <option value="14:00~15:00">14:00~15:00</option>
                                                        <option value="15:00~16:00">15:00~16:00</option>
                                                        <option value="16:00~17:00">16:00~17:00</option>
                                                        <option value="17:00~18:00">17:00~18:00</option>
                                                        <option value="18:00~19:00">18:00~19:00</option>
                                                        <option value="19:00~20:00">19:00~20:00</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="am-g am-margin-top">
                                                <div class="am-u-sm-2 am-text-right">
                                                    配送员
                                                </div>
                                                <div class="am-u-sm-4 am-u-end">
                                                    <select name="ps_yuan">
                                                        <option value="">--请选择--</option>
                                                        <foreach name="ps_datas" item="ps_data">
                                                            <option value="{$ps_data.name}">{$ps_data.name}</option>
                                                        </foreach>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="am-margin">
                                                <input type="submit" name="" value="添加时间"
                                                       class="am-btn am-btn-primary am-btn-sm am-fl">
                                            </div>
                                        </form>
                                    </div>
                                </if>
                                <!--配送操作-end-->
                                <if condition="$data.status eq 3">
                                    <a href="__URL__/order_psEnd/id/{$data.omid}">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                                            完成配送
                                        </button>
                                    </a>
                                    <a href="__URL__/ps_print/id/{$data.omid}">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                                            打印
                                        </button>
                                    </a>
                                </if>
                                <a href="__URL__/../Order/orderDetail/id/{$data.omid}">
                                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                                        详情
                                    </button>
                                </a>
                                <if condition="session('role') eq 0">
                                    <if condition="$data.status eq 3">
                                    <a href="__URL__/psOrderBelong/id/{$data.omid}">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-success">
                                            分配配送
                                        </button>
                                    </a>
                                    </if>
                                    <a href="__URL__/orderDel2/id/{$data.omid}" onclick="return del()">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger">
                                            <span class="am-icon-trash-o"></span>删除
                                        </button>
                                    </a>
                                </if>
                            </div>
                        </div>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="am-cf">
            {$page}
        </div>
    </div>
</div>
</div>
<!-- content end -->
</div>
<script src="__PUBLIC__/assets/js/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
    function del() {
        if (!confirm("确认删除？")) {
            window.event.returnValue = false;
        }
    }
    function ps(id) {
        window.rs = id;
        document.getElementById(id).style.display = 'block';
        document.getElementById("p" + id).style.display = 'block';
    }
    $(function () {
        $("#close").click(function () {
            $(".shadow").css('display', 'none');
            $(".popbox").fadeOut('fast');
        });
    })
    $("#all").click(function () {
        if (this.checked) {
            $(".check").attr("checked", true);
        } else {
            $(".check").attr("checked", false);
        }
    });
    //    批量分配工厂ajax
    $("#getValue").click(function () {
        var arr = new Array;
        $("input[name='omid[]']:checked").each(function () {
            arr.push($(this).val());
        });
        $.post(
                "http://001.hitailor.com/Batch/batchGet",
                {"omids": arr},
                function (data) {
                    window.location.href = "http://001.hitailor.com/Batch/batchBelongGc/ids/" + data.content;
                }
        );
    });
    //    批量打印ajax
    $("#getPrintValue").click(function () {
        var arr = new Array;
        $("input[name='omid[]']:checked").each(function () {
            arr.push($(this).val());
        });
        $.post(
                "http://001.hitailor.com/Batch/batchGet",
                {"omids": arr},
                function (returnData) {
                    if (returnData.status == 1) {
                        window.location.href = "http://001.hitailor.com/Batch/batchPrint2/id/" + returnData.content;
                    } else {
                        alert(returnData.content);
                    }
                }
        );
    });
    //批量完成配送AJAX
    $("#getPsEndValue").click(function () {
        var arr = new Array;
        $("input[name='omid[]']:checked").each(function () {
            arr.push($(this).val());
        });
        $.post(
                "http://001.hitailor.com/Batch/batchGet",
//                "http://localhost/thinkphp/index.php/Admin/Batch/batchGet",
                {"omids": arr},
                function (returnData) {
                    window.location.href = "http://001.hitailor.com/Batch/batchPsEnd/id/" + returnData.content;
//                        window.location.href="http://localhost/thinkphp/index.php/Admin/Batch/batchPsEnd/id/"+returnData.content;
                }
        );
    });
    //批量配送AJAX
    $("#getValuePs").click(function () {
        var arr = new Array;
        $("input[name='omid[]']:checked").each(function () {
            arr.push($(this).val());
        });
        $.post(
                "http://001.hitailor.com/Batch/batchGet",
//                "http://localhost/thinkphp/index.php/Admin/Batch/batchGet",
                {"omids": arr},
                function (returnData) {
                    window.location.href = "http://001.hitailor.com/Batch/batchPs/ids/" + returnData.content;
//                        window.location.href="http://localhost/thinkphp/index.php/Admin/Batch/batchPs/ids/"+returnData.content;
                }
        );
    });
    //批量分配配送员
    $("#getPsBelongValue").click(function () {
        var arr = new Array;
        $("input[name='omid[]']:checked").each(function () {
            arr.push($(this).val());
        });
        $.post(
                "http://001.hitailor.com/Batch/batchGet",
//                "http://localhost/thinkphp/index.php/Admin/Batch/batchGet",
                {"omids": arr},
                function (returnData) {
                    window.location.href = "http://001.hitailor.com/Batch/batchPsBelong/ids/" + returnData.content;
//                    window.location.href="http://localhost/thinkphp/index.php/Admin/Batch/batchPsBelong/ids/"+returnData.content;
                }
        );
    });
</script>
<include file="public/footer"/>